package com.triones.ljr.controller.web;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.triones.ljr.entity.dto.WxUserDO;
import com.triones.ljr.entity.vo.WxUserVO;
import com.triones.ljr.service.WxUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 微信用户
 *
 * @Author: triones
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/wxUser")
public class WxUserController extends BaseController {

    private final WxUserService wxUserService;

    /**
     * 列表（分页）
     */
    @SaCheckPermission("system:wxUser:pageList")
    @GetMapping("/pageList")
    public TableDataInfo<WxUserVO> pageList(WxUserDO dto, PageQuery pageQuery) {
        return wxUserService.pageList(dto, pageQuery);
    }

    /**
     * 禁用/启用
     */
    @SaCheckPermission("system:wxUser:changeStatus")
    @Log(title = "微信用户", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public R<Void> changeStatus(@RequestBody WxUserDO dto) {
        return toAjax(wxUserService.updateStatus(dto));
    }

    /**
     * 密码重置
     */
    @SaCheckPermission("system:wxUser:pwdReset")
    @Log(title = "微信用户", businessType = BusinessType.UPDATE)
    @PutMapping("/pwdReset")
    public R<Void> pwdReset(@RequestBody WxUserDO dto) {
        return toAjax(wxUserService.pwdReset(dto));
    }
}
